package day8;

//通过线程模拟病人看病的功能
//第一类病人: 是普通用户 50人 看病时长:500ms
//优先级低一些
//第二类病人: 是VIP用户 10人 看病时长:1000ms
//优先级会高一些
//如果普通用户看完了10人优先看完VIP用户再看普通用户
public class Demo {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            String name = Thread.currentThread().getName();
            for (int i = 0; i < 10; i++) {
                System.out.println("第" + (i + 1) + "个" + name);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "VIP用户");
        Thread t2 = new Thread(() -> {
            String name = Thread.currentThread().getName();
            for (int i = 0; i < 50; i++) {
                System.out.println("第" + (i + 1) + "个" + name);
                try {
                    Thread.sleep(500);
                    if (i == 9) t.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "普通用户");

        t.setPriority(Thread.MAX_PRIORITY);     //t.setPriority(10)
        t2.setPriority(Thread.MIN_PRIORITY);
        t.start();
        t2.start();

    }
}